package model.cnf;

/**
 * represente a literal.
 * 
 * @author GRONOWSKI Stephane svan001@aol.com
 * 
 *         igsat 2010
 * 
 */
public class Literal {

	int	value;

	/**
	 * Create a new literal.
	 * 
	 * @param value
	 *            value of the literal.
	 */
	public Literal(int value) {
		this.value = value;
	}

	/**
	 * Create a new literal.
	 * 
	 * @param var
	 *            value of the literal.
	 * @param polarity
	 *            polarity of the literal.
	 */
	public Literal(int var, boolean polarity) {
		value = (polarity ? var : -var);
	}

	/**
	 * 
	 * @return a literal with the opposite value of the current literal.
	 */
	public Literal oppositeLiteral() {
		return new Literal(-value);
	}

	@Override
	public String toString() {
		return String.valueOf(value);
	}

	/**
	 * @return the literal.
	 */
	public int getVar() {
		return Math.abs(value);
	}

}
